include Bzflag
require "date"

module BZCommon

  def get_team_color(team_id)
  
    if RogueTeam == team_id
      team = "Rogue"
    elsif RedTeam == team_id
      team = "Red Team"
    elsif GreenTeam == team_id
      team = "Green Team"
    elsif BlueTeam == team_id
      team = "Blue Team"
    elsif PurpleTeam == team_id
      team = "Purple Team"
    elsif RabbitTeam == team_id
      team = "rabbit"
    elsif HunterTeam == team_id
      team = "hunter"
    elsif Observers == team_id
      team = "observer"
    elsif Administrators == team_id
      team = "admin"
    else 
      team = "unknown"
    end
  
    return team
  end

  def is_server_player(id)
     return id == 253 
  end
  
  def is_score_max(player)
      score = player.wins - player.losses
      if score + 1 == 20
        return true
      else
        return false
      end 
  end
  
  def get_date
   return Date::today.to_s
  end
  
  def get_time
    @time = Time.new
    return @time.hour.to_s + "-" + @time.min.to_s + "-" + @time.sec.to_s  
  end
  
  def get_winner
   
    ids = bz_get_player_index_list
    
    winner = Player.new(ids[0]);
    
    ids.each do |id|
        player = Player.new(id)
        score = player.wins - player.losses
        winnerScore = winner.wins - winner.losses
        
        if (score > winnerScore)
          winner = player
        end
    end
    
  
   return winner   
  end

end